<template>
  <div class="detail">
    <div class="left">
      <div class="info-list">
        <div
          class="info-item"
          v-for="(item, index) in infoList"
          :key="index"
          :class="{ active: position === item.value }"
          @click="infoItemClick(item, index)"
        >
          {{ item.label }}
        </div>
      </div>
    </div>
    <div class="right">
      <div v-if="position === '1'">
        <reminders></reminders>
      </div>
      <div v-if="position === '2'">
        <todoList></todoList>
      </div>
      <div v-if="position === '3'">
        <publicOpinionInformation></publicOpinionInformation>
      </div>
    </div>
  </div>
</template>

<script>
import reminders from "./components/reminders.vue";
import todoList from "./components/todoList.vue";
import publicOpinionInformation from "./components/publicOpinionInformation.vue";
export default {
  name: "platform",
  components: {
    reminders,
    todoList,
    publicOpinionInformation,
  },
  data() {
    return {
      position: "1",
      infoList: [
        {
          label: "提醒事项",
          value: "1",
          isActive: false,
        },
        {
          label: "待办事项",
          value: "2",
          isActive: false,
        },
        {
          label: "舆情信息",
          value: "3",
          isActive: false,
        },
      ],
    };
  },
  watch: {
    $route: {
      immediate: true,
      handler(value) {
        this.getCurrentActive();
      },
    },
  },
  mounted() {
    this.getCurrentActive();
  },

  methods: {
    getCurrentActive() {
      const path = this.$route.path;
      console.log("path", path);
      const index = path.split("details/")[1];
      if (index === "one") {
        this.position = "1";
      }
      if (index === "two") {
        this.position = "2";
      }
      if (index === "three") {
        this.position = "3";
      }
    },
    infoItemClick(item, index) {
      this.position = item.value;
    },
  },
};
</script>

<style lang="scss" scoped>
.detail {
  display: flex;
  color: #fff;
  .left {
    width: 200px;
    background-color: #262d47;
    height: 100%;
    .info-list {
      padding: 10px;
      .info-item {
        margin-bottom: 2px;
        height: 40px;
        line-height: 40px;
        text-align: center;
        // background-color: #363657;
        color: #959fc5;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        &:hover {
          background-color: #1c2238 !important;
          color: #fff;
          cursor: pointer;
        }
      }
      .active {
        background-color: #1c2238 !important;
        color: #fff;
      }
    }
  }
  .right {
    flex: 1;
    background-color: #262d47;
    height: 100%;
    margin-left: 10px;
  }
}
</style>
